package edu.pdx.cs.cs542s07.minichess;

public class MoveTester {

	private static void testHelper(String boardString, int fromRow, int fromCol,
			int toRow, int toCol) {
		
		System.out.println("Begin test.\n");
		System.out.println("Before move:");
		System.out.println(boardString + "\n");
		
		Board state;
		try {
			state = new Board(boardString);
		} catch (IllegalBoardStringException e) {
			e.printStackTrace(System.out);
			return;
		}
		
		Square to 	= new Square(toRow, toCol);
		Square from = new Square(fromRow, fromCol);
		Move move 	= new Move(from, to);
		System.out.println("Move: " + move.toString());
		
		try {
			state.move(move);
		} catch (IllegalMoveException e) {
			// Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("After move:");
		System.out.println(state.toString() + "\nEnd Test\n");
		
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		String boardString;
		
		//move a piece
		boardString = 	"0 W\n" +
		".....\n" +
		".....\n" +
		"..Q..\n" +
		".....\n" +
		".....\n" +
		".....\n";
		testHelper(boardString, 3, 2, 3, 4);
		
		// Capture
		boardString = 	"0 B\n" +
		".....\n" +
		".....\n" +
		"..Q.r\n" +
		".....\n" +
		".....\n" +
		".....\n";
		testHelper(boardString, 3, 4, 3, 2);
		
		//move a pawn non-promoting
		boardString = 	"0 W\n" +
		".....\n" +
		".....\n" +
		"..P..\n" +
		".....\n" +
		".....\n" +
		".....\n";
		testHelper(boardString, 3, 2, 4, 2);
		
		//move a pawn promoting
		//move a pawn non-promoting
		boardString = 	"0 W\n" +
		".....\n" +
		"..P..\n" +
		".....\n" +
		".....\n" +
		".....\n" +
		".....\n";
		testHelper(boardString, 4, 2, 5, 2);
		

	}

}
